Skip to content

Conversation

@sanjaysgk
Copy link
Collaborator

@sanjaysgk sanjaysgk commented Jun 19, 2025

…n options; improve handling of x-tick labels across subplots

Summary by Sourcery

Enhance x-tick label customization in the Peptigram visualization by exposing font size, color, and rotation options, streamline x-tick label display across subplots, and adjust function signature and default titles for clarity.

New Features:

  • Add xticks_font, xticks_color, and xticks_rotation parameters to plot_peptigram for customizable x-axis tick styling
  • Hide intermediate x-axis tick labels and apply styling only on the bottom subplot for improved label handling across subplots

Enhancements:

  • Annotate plot_peptigram to return a Tuple of Figure and Axes
  • Refine the default plot title in runner.py for clearer peptide-protein alignment wording
  • Polish internal comments for cleaner code readability

Documentation:

  • Update plot_peptigram docstrings to describe new x-tick customization options

…n options; improve handling of x-tick labels across subplots
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 19, 2025

Reviewer's Guide

This PR extends x-axis tick label customization in plot_peptigram by introducing font size, color, and rotation options, implements logic to apply these settings only on the bottom subplot while hiding labels on intermediate axes, and updates the default plot title in runner.py.

Class diagram for updated plot_peptigram function parameters

classDiagram
    class plot_peptigram {
        +int x_lab_forntsize = 12
        +int y_lab_forntsize = 12
        +int xticks_font = 12
        +str xticks_color = "#333333"
        +int xticks_rotation = 0
        +bool annotate = True
        +Optional[float] min_intensity
        +Optional[List[Tuple[int, int]]] highlight_regions
        +float highlight_alpha = 0.25
        +str highlight_color = "#FF8888"
        +int dpi = 300
        +Tuple[plt.Figure, List[plt.Axes]] plot_peptigram(...)
    }
Loading

File-Level Changes

Change Details Files
Add xticks customization parameters to plot_peptigram
  • Extend function signature with xticks_font, xticks_color, xticks_rotation arguments
  • Update docstring to describe new xticks_* parameters
  • Annotate return type as Tuple[plt.Figure, List[plt.Axes]]
ProtPeptigram/viz.py
Implement per-axes x-tick label handling
  • Insert loop over axs to hide x-tick labels on all but the bottom subplot
  • Apply tick_params with xticks_font, xticks_color, xticks_rotation on the last axis
ProtPeptigram/viz.py
Update default plot title in runner
  • Change title template to “Peptide-Protein alignment visualisation – {prot}”
ProtPeptigram/runner.py
Refine inline comments and formatting
  • Adjust comment text (“publication-quality” → “high quality”),
  • Remove extraneous blank lines
ProtPeptigram/viz.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sanjaysgk sanjaysgk merged commit 833291a into main Jun 19, 2025
3 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sanjaysgk - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `ProtPeptigram/viz.py:53` </location>
<code_context>
         title: Optional[str] = None,
         x_lab_forntsize: int = 12,
         y_lab_forntsize: int = 12,
+        xticks_font: int = 12,
+        xticks_color: str = "#333333",
+        xticks_rotation: int = 0,
         annotate: bool = True,
         min_intensity: Optional[float] = None,
</code_context>

<issue_to_address>
Parameter naming is inconsistent between function signature and docstring.

The docstring uses 'x_ticks_rotation' while the parameter is 'xticks_rotation'. Please use the same name in both for clarity.

Suggested implementation:

```python
        x_ticks_rotation: int = 0,

```

```python
        """
        Create a PeptiGram visualization with protein-based coloring.

            Font size for x-axis labels Amino acid positions(default: 12)
            x_ticks_rotation: int
                Rotation angle for x-axis tick labels (default: 0)

```

```python
        # ... (usage in function body)
        ax.set_xticklabels(labels, fontsize=xticks_font, color=xticks_color, rotation=x_ticks_rotation)

```
</issue_to_address>

### Comment 2
<location> `ProtPeptigram/runner.py:187` </location>
<code_context>
                 group_by='Sample',
                 color_by='protein',
                 figsize=(14, 12),
-                title=f"Peptide Visualization - {prot}",
+                title=f"Peptide-Protein alignment visualisation - {prot}",
                 color_by_protein_and_intensity=False,
                 intensity_cmaps=["Blues", "Reds", "Greens", "Purples"],
</code_context>

<issue_to_address>
Title spelling is inconsistent with US/UK English conventions.

Consider updating the spelling to match the convention used elsewhere in the project.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
                title=f"Peptide-Protein alignment visualisation - {prot}",
=======
                title=f"Peptide-Protein alignment visualization - {prot}",
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +53 to +55
xticks_font: int = 12,
xticks_color: str = "#333333",
xticks_rotation: int = 0,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Parameter naming is inconsistent between function signature and docstring.

The docstring uses 'x_ticks_rotation' while the parameter is 'xticks_rotation'. Please use the same name in both for clarity.

Suggested implementation:

        x_ticks_rotation: int = 0,
        """
        Create a PeptiGram visualization with protein-based coloring.

            Font size for x-axis labels Amino acid positions(default: 12)
            x_ticks_rotation: int
                Rotation angle for x-axis tick labels (default: 0)
        # ... (usage in function body)
        ax.set_xticklabels(labels, fontsize=xticks_font, color=xticks_color, rotation=x_ticks_rotation)

group_by='Sample',
color_by='protein',
figsize=(14, 12),
title=f"Peptide Visualization - {prot}",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Title spelling is inconsistent with US/UK English conventions.

Consider updating the spelling to match the convention used elsewhere in the project.

Suggested change
title=f"Peptide Visualization - {prot}",
title=f"Peptide-Protein alignment visualization - {prot}",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants